* GSS data setup for: 
* Unions, Class Identification and Policy Attitudes
* Date: 03/31/22


* This code was created by Stephen L. Morgan and can be found at:
* https://osf.io/9nkrw/


********************************************************************************
*** Import csv crosswalk file and save as temporary merge file
********************************************************************************

tempfile egp_merge_file

import delimited using "occ10-to-egp-class-crosswalk.csv"
drop egp_label
save `egp_merge_file'

********************************************************************************
*** Load GSS data
********************************************************************************

use GSS_SubClass.dta, clear

********************************************************************************
*** Merge EGP codes by occ10
********************************************************************************

merge m:1 occ10 using `egp_merge_file'
tab _merge
list title if _merge==2
drop _merge

********************************************************************************
*** Label 10-class version of EGP (with combined class IVab)
********************************************************************************

tab egp10_10, miss
label define egproman10 1 "I" 2 "II" 3 "IIIa" 4 "IIIb" 7 "IVc" 8 "V" ///
  9 "VI" 10 "VIIa" 11 "VIIb" 12 "Military"
label values egp10_10 egproman10
tab egp10_10, miss
tab egp10_10 wrkstat, miss

********************************************************************************
*** Create 11-class version (with combined class IVab)
********************************************************************************

gen egp10_11 = egp10_10
replace egp10_11 = 5 if egp10_10 != 1 & egp10_10 != 2 & egp10_10 != 7 ///
        & egp10_10 != 12 & egp10_10 != . & wrkslf == 1 
label define egproman11 1 "I" 2 "II" 3 "IIIa" 4 "IIIb" 5 "IVab" 7 "IVc" ///
  8 "V" 9 "VI" 10 "VIIa" 11 "VIIb" 12 "Military"
label values egp10_11 egproman11
tab egp10_11 wrkslf, miss
tab egp10_11 wrkstat, miss
tab egp10_10 egp10_11, miss

